/*    */ package com.newcrm.webapi.sub;
/*    */ 
/*    */ import com.newcrm.bean.CompanyInfo;
/*    */ import com.newcrm.bean.Group;
/*    */ import com.newcrm.bean.User;
/*    */ import com.newcrm.db.DealManager;
/*    */ import com.newcrm.exception.NotFoundException;
/*    */ import com.newcrm.util.Util;
/*    */ import com.newcrm.webapi.AbstractAction;
/*    */ import com.newcrm.webapi.AbstractHttpServlet;
/*    */ import java.io.IOException;
/*    */ import java.io.PrintWriter;
/*    */ import java.util.Date;
/*    */ import java.util.List;
/*    */ import javax.servlet.ServletException;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import net.sf.json.JSONObject;
/*    */ 
/*    */ public class ShowDealMoneyChart extends AbstractAction
/*    */ {
/*    */   public ShowDealMoneyChart(AbstractHttpServlet servlet)
/*    */   {
/* 27 */     super(servlet);
/*    */   }
/*    */ 
/*    */   public void parse(HttpServletRequest request, HttpServletResponse response)
/*    */     throws IOException, ServletException, NotFoundException
/*    */   {
/* 36 */     response.setContentType("text/html;charset=utf-8");
/* 37 */     PrintWriter out = response.getWriter();
/* 38 */     JSONObject jsonObject = new JSONObject();
/*    */ 
/* 40 */     User user = super.getLoginUser(request);
/*    */ 
/* 42 */     if ((!user.isAdmin) && (!user.isGroupAdmin)) {
/* 43 */       jsonObject.put("error", "1");
/* 44 */       out.println(jsonObject);
/* 45 */       out.flush();
/* 46 */       out.close();
/* 47 */       return;
/*    */     }
/*    */ 
/* 50 */     String groupIds = "";
/*    */ 
/* 52 */     if (!user.isAdmin) {
/* 53 */       CompanyInfo company = super.getCompany(request);
/* 54 */       Group group = company.getGroupById(user.groupId);
/* 55 */       if (group != null)
/* 56 */         groupIds = group.getAllIds();
/*    */       else {
/* 58 */         groupIds = String.valueOf(user.groupId);
/*    */       }
/*    */     }
/*    */ 
/* 62 */     Date startDate = Util.str2Date(request.getParameter("start"));
/* 63 */     Date endDate = Util.str2Date(request.getParameter("end"));
/*    */ 
/* 65 */     DealManager manager = new DealManager();
/* 66 */     List result = manager.getWonDealsInfo(
/* 67 */       user.companyId, groupIds, startDate, endDate);
/* 68 */     jsonObject.put("error", "0");
/* 69 */     jsonObject.put("result", result);
/* 70 */     out.println(jsonObject);
/* 71 */     out.flush();
/* 72 */     out.close();
/*    */   }
/*    */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.webapi.sub.ShowDealMoneyChart
 * JD-Core Version:    0.6.1
 */